package edu.bbu.commonproject.desktop.client.services;

import java.util.ArrayList;

import edu.bbu.commonproject.desktop.client.exceptions.FileDownloadException;
import edu.bbu.commonproject.desktop.client.exceptions.FileOperationException;
import edu.bbu.commonproject.desktop.client.exceptions.FileUploadException;
import edu.bbu.commonproject.desktop.client.exceptions.NoConnectionException;
import edu.bbu.commonproject.desktop.client.exceptions.TransferInterruptedException;
import edu.bbu.commonproject.desktop.client.model.DirectoryPOJO;
import edu.bbu.commonproject.desktop.client.model.FilePOJO;
import edu.bbu.commonproject.desktop.client.utils.FileTransferObserver;
import edu.bbu.commonproject.desktop.client.exceptions.DataBaseErrorException;

/**
 * Interface that all file service implamentation must suport.
 */
public interface FileCLTServices
{
	/**
	 * Uploading a file.
	 * @param file the file information.
	 * @throws FileUploadException if the connection lost.
	 */
	public abstract void uploadFile(FilePOJO file, FileTransferObserver observer) throws FileUploadException, TransferInterruptedException;
	
	/**
	 * Downloading a file.
	 * @param file the file information
	 * @throws FileDownloadException if the connection lost.
	 */
	public abstract void downloadFile(FilePOJO file, FileTransferObserver observer) throws FileDownloadException, TransferInterruptedException;
	
	/**
	 * Deleting a file, wit a specified version.
	 * @param file the file information.
	 */
	public abstract void deleteFile(FilePOJO file) throws NoConnectionException, FileOperationException, DataBaseErrorException;
	
	/**
	 * Delete a file with all of the versions.
	 * @param file the file information.
	 * @throws NoConnectionException if the connection lost.
	 * @throws FileOperationException if the opertion failed.
	 */
	public abstract void deleteAllFileVersions(FilePOJO file) throws NoConnectionException, FileOperationException, DataBaseErrorException;
	
	/**
	 * Getting the last file version.
	 * @param file the file information.
	 * @return the last file version number.
	 * @throws NoConnectionException if the connection lost.
	 * @throws FileOperationException if the opertion failed.
	 */
	public abstract int getLastFileVersionNumber(FilePOJO file) throws NoConnectionException, FileOperationException, DataBaseErrorException;
	
	/**
	 * Getting all the existinf gile version numbers.
	 * @return a list of all file version numbers.
	 * @throws NoConnectionException if the connection lost.
	 * @throws FileOperationException if the opertion failed.
	 */
	public abstract ArrayList<Integer> getAllFileVersions(FilePOJO file) throws NoConnectionException, FileOperationException, DataBaseErrorException;
	
	/**
	 * Getting the file list from a directory.
	 * @param directoryPOJO the directory information.
	 * @return a list of strings with the file names.
	 * @throws NoConnectionException if the connection lost.
	 */
	public abstract ArrayList<String> getFilesFromDirectory(DirectoryPOJO directoryPOJO) throws NoConnectionException, DataBaseErrorException;
	
	/**
	 * Getting the size of file in bytes.
	 * @param filePOJO the filePOJO. It must contain the owner, file name and direcoty name.
	 * @return the file size in bytes.
	 * @throws NoConnectionException if the connection lost.
	 */
	public abstract long getFileSize(FilePOJO filePOJO) throws NoConnectionException, FileOperationException, DataBaseErrorException;
	
	/**
	 * Getting the size of file upload date.
	 * @param filePOJO the filePOJO. It must contain the owner, file name and direcoty name.
	 * @return the file size in bytes.
	 * @throws NoConnectionException if the connection lost.
	 */
	public abstract long getFileUploadDate(FilePOJO filePOJO) throws NoConnectionException, FileOperationException, DataBaseErrorException;
	
}
